/**
 * 
 */
package org.ucn.dmaa0914.gruppe6.tests;

import static org.junit.Assert.*;

import java.util.Date;

import org.junit.Before;
import org.junit.Test;
import org.ucn.dmaa0914.gruppe6.Customer;
import org.ucn.dmaa0914.gruppe6.CustomerCtr;
import org.ucn.dmaa0914.gruppe6.Employee;
import org.ucn.dmaa0914.gruppe6.ItemCtr;
import org.ucn.dmaa0914.gruppe6.Order;
import org.ucn.dmaa0914.gruppe6.OrderCtr;
import org.ucn.dmaa0914.gruppe6.PartOrder;

/**
 * @author Kim Johannsen
 * @version 09-12-2014
 *
 */
public class OrderTest {

	private Order order;
	
	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	@Before
	public void setUp() throws Exception {
		HardCodedObjects.addToControllers();
		CustomerCtr.getInstance().setCurrentCustomer(HardCodedObjects.customers.get(0).getId());
		order = HardCodedObjects.orders.get(0);
	}

	/**
	 * Test method for {@link org.ucn.dmaa0914.gruppe6.Order#addPartOrder(org.ucn.dmaa0914.gruppe6.PartOrder)}.
	 */
	@Test
	public void testAddPartOrder() {
		PartOrder po = new PartOrder(ItemCtr.getInstance().search("").get(0), 7);
		order.getPartOrders().add(po);
		
		assertSame(order.getPartOrders().get(order.getPartOrders().size()-1), po);
	}

	/**
	 * Test method for {@link org.ucn.dmaa0914.gruppe6.Order#setId(int)}.
	 */
	@Test
	public void testSetId() {
		order.setId(8);
		assertEquals(order.getId(), 8);
	}

	/**
	 * Test method for {@link org.ucn.dmaa0914.gruppe6.Order#setDate(java.util.Date)}.
	 */
	@Test
	public void testSetDate() {
		Date d = new Date();
		
		order.setDate(d);
		assertEquals(order.getDate(), d);
	}

	/**
	 * Test method for {@link org.ucn.dmaa0914.gruppe6.Order#setPaid(boolean)}.
	 */
	@Test
	public void testSetPaid() {
		order.setPaid(true);
		assertEquals(order.isPaid(), true);
	}

	/**
	 * Test method for {@link org.ucn.dmaa0914.gruppe6.Order#setEmployee(org.ucn.dmaa0914.gruppe6.Employee)}.
	 */
	@Test
	public void testSetEmployee() {
		Employee e = HardCodedObjects.employees.get(0);
		order.setEmployee(e.getId());
		assertEquals(order.getEmployee(), e.getId());
	}

	/**
	 * Test method for {@link org.ucn.dmaa0914.gruppe6.Order#setCustomer(org.ucn.dmaa0914.gruppe6.Customer)}.
	 */
	@Test
	public void testSetCustomer() {
		Customer c = CustomerCtr.getInstance().search("").get(0);
		order.setCustomer(c.getId());
		assertEquals(order.getCustomer(), c.getId());
	}

}
